/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ies.domain.model.web.util;

import com.sun.net.httpserver.HttpServer;
import java.io.Serializable;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.spi.http.HttpContext;
import org.jboss.weld.context.http.HttpRequestContext;

/**
 *
 * @author gustavo
 */
public class AbstractManagedBean implements Serializable {

    public Object getApplicatioBean(String bean) {
        FacesContext context = FacesContext.getCurrentInstance();
        Object object = context.getApplication().getELResolver().getValue(context.getELContext(), null, bean);
        return object;
    }

    public Object getRequestBean(String bean) {
        FacesContext context = FacesContext.getCurrentInstance();
        Object object = context.getExternalContext().getRequestMap().get(bean);
        return object;
    }

    public Object getViewBean(String bean) {
        FacesContext context = FacesContext.getCurrentInstance();
        Object object = context.getViewRoot().getViewMap().get(bean);
        return object;
    }

    public Object getSessionBean(String bean) {
        FacesContext context = FacesContext.getCurrentInstance();
        Object object = context.getExternalContext().getSessionMap().get(bean);
        return object;
    }

    public String getRequestParam(String bean) {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        return request.getParameter(bean);
    }
}
